class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  
  before_action :beta_authenticate
  before_action :get_profile

protected
  def beta_authenticate
    authenticate_or_request_with_http_basic do |username, password|
      username == "betauser" && password == "test"
    end
  end

  def admin_required
    unless current_user && current_user.is_admin?
      flash[:error] = "Sorry, you don't have access to that page!"
      redirect_to root_url and return false
    end
  end

  def get_profile
    if session[:current_profile].present?
      @profile = Profile.find(session[:current_profile])
    end
  end

end
